package com.zy1;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import com.zy1.service.UserService;
import java.util.Scanner;
import java.util.UUID;

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) {
//        logger.info("===== 程序启动 =====");
//        Scanner scanner = new Scanner(System.in);
//        UserService userService = new UserService();
//
//        while (true) {
//            System.out.print("\n请输入用户名（输入 exit 退出）: ");
//            String username = scanner.nextLine();
//            if ("exit".equalsIgnoreCase(username)) break;
//
//            // 为每个“请求”生成一个唯一的 requestId
//            String reqId = UUID.randomUUID().toString().substring(0, 8);
//            MDC.put("reqId", "(reqId=" + reqId + ")");
//
//            logger.info("收到用户输入: {}", username);
//            try {
//                userService.processUser(username);
//            } catch (Exception e) {
//                logger.error("用户处理异常！", e);
//            } finally {
//                // 清理上下文，防止污染下一次请求
//                MDC.clear();
//            }
//        }
//
//        logger.info("===== 程序结束 =====");
        LoginService service = new LoginService();
        service.login("admin", "123456");
        service.login("user", "wrongpass");
    }
}
